home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1986 June / Ahoy_Magazine_86-06_1986_Double_L.d64 / comal and you < prev    next >
Text File  |  2022-10-26  |  9KB  |  332 lines

  1. COMAL AND YOU - For Beginners Only
  2. by David Stidolph
  3. WHY LEARN TO PROGRAM?
  4.  
  5. The many commercial computer programs
  6. available today are more than
  7. sufficient for most people's needs.
  8. If word processors, spread sheets,
  9. and data base managers are all the
  10. computer is used for, learning to
  11. program would be a waste of time.
  12.  
  13. For some, however, a goal is being
  14. able to learn something new...
  15. something that can control that
  16. mysterious box called a computer.
  17. There's nothing like the feeling of
  18. accomplishment when you type in your
  19. first working program. Also,
  20. familiarity with computers and
  21. programming helps ease the sense of
  22. helplessness most people get when
  23. dealing with computers. (How did you
  24. feel the first time you got a
  25. computerized bill?) This article is
  26. for people who have made the decision
  27. to not only learn about computers,
  28. but to learn programming as well.
  29.  
  30. WHAT IS A COMPUTER LANGUAGE?
  31.  
  32. Computers work with a language of
  33. zeros and ones called machine code.
  34. This is as difficult to use as it
  35. sounds, and few programmers now work
  36. directly in machine code. They choose
  37. instead to use computer "languages".
  38. These range from low level languages
  39. like assembly code, where the words
  40. merely represent individual machine
  41. code instructions, to high level
  42. languages which look more like
  43. english. Compare the following two
  44. programs:
  45.  
  46. ASSEMBLY CODE
  47.  
  48.        * =  START
  49.        LDY  #0
  50. LP     LDA  STRING,Y
  51.        BEQ  ENDLP
  52.        JSR  OUTPUT
  53.        INY
  54.        BNE  LP
  55.        BEQ  OUTPUT
  56.        .BYT 'This is a string',13,0
  57. ENDLP  <...>  ; rest of program code
  58.  
  59. COMAL
  60.  
  61. PRINT "This is a string"
  62.  
  63. As you can see, the COMAL program is
  64. shorter and much more readable.
  65. Although the computer will seem to
  66. understand COMAL once the language is
  67. loaded, the computer itself still
  68. only understands machine code. COMAL
  69. is itself a machine code program, but
  70. instead of letting you do word
  71. processing, or other mundane tasks,
  72. it allows you to write, edit, and run
  73. COMAL programs. Think of the language
  74. as an interpreter between you and the
  75. computer. This means you don't have
  76. to learn machine code - you only have
  77. to make sure that the language is in
  78. the machine before you can run your
  79. COMAL programs.
  80.  
  81. WHY LEARN COMAL?
  82.  
  83. Since BASIC comes with all personal
  84. computers today, most people think
  85. that it is the best computer language
  86. to learn. Not so. BASIC is
  87. implemented on so many computers
  88. because it is the easiest language to
  89. write. It has the fewest commands,
  90. and NO definite standard to follow
  91. (any arbitrary rules can be forced on
  92. it). This means that a BASIC program
  93. written on one computer may NOT run
  94. on any other computer. BASIC does,
  95. however, have one good feature; the
  96. ability to type in a short program
  97. and see it execute as soon as you
  98. type the word RUN. No text editors or
  99. elaborate compiler commands (needed
  100. in most other high level languages
  101. like Pascal, Fortran or Cobol) are
  102. necessary. This makes BASIC seem like
  103. a easy-to-learn language for
  104. everyone.
  105.  
  106. COMAL started with this idea of
  107. interactive work with the programmer,
  108. then added to it. Added were things
  109. like the structured code of Pascal,
  110. the graphics of Logo, and a few
  111. tricks of its own. COMAL is now the
  112. language taught in the schools of 5
  113. European countries. COMAL is easier
  114. to learn than BASIC, and teaches the
  115. idea of structured programing
  116. necessary to using modern computer
  117. languages.
  118.  
  119. HOW DO YOU GET COMAL?
  120.  
  121. In Europe, the disk based version of
  122. COMAL for the Commodore 64 (version
  123. 0.14 - the same as used here in the
  124. U.S.) sells for fifty dollars, and is
  125. copy-protected so that you cannot
  126. make copies of it. Here in the United
  127. States we are fortunate that the same
  128. disk based COMAL is available from
  129. most local User Groups or may be
  130. ordered directly from COMAL Users
  131. Group, USA, Limited (for under $20).
  132. These disks are NOT copy protected,
  133. and you can legally make as many
  134. copies as you want. It is this disk
  135. based version of COMAL for the
  136. Commodore 64 that I am going to talk
  137. about here.
  138.  
  139. Once you have a COMAL disk, you must
  140. load COMAL into the computer before
  141. you can run any programs written in
  142. COMAL. To load COMAL, turn on the
  143. computer system, insert the COMAL
  144. disk in the disk drive (label side
  145. up), and type in the following lines
  146. from BASIC (when you turn the
  147. computer on, it has BASIC going - if
  148. you are using a C128, it must be in
  149. C64 mode). Remember to press the
  150. RETURN key after each line:
  151.  
  152.    LOAD "BOOT*",8
  153.    RUN
  154.  
  155. The screen will display some
  156. information about COMAL and begin to
  157. load COMAL into the computer. When
  158. the language is finished loading, a
  159. COMAL program called "HI" is
  160. automatically RUN. The reason that
  161. COMAL runs this program is that the
  162. first program you loaded ("BOOT*")
  163. set it up so it would. Most COMAL
  164. 0.14 disks from COMAL Users Group USA
  165. include a "HI" program, and on most
  166. of those disks the "HI" program is
  167. specific to that disk. This sounds
  168. complicated, and it is, but each one
  169. was written to do certain things
  170. needed for that disk. If you are
  171. expected to do anything, directions
  172. will be printed on the screen. For
  173. now I just want you to get and run
  174. COMAL.
  175.  
  176. WHAT DO I DO WITH COMAL?
  177.  
  178. The purpose of COMAL is for YOU to
  179. learn how to write readable programs,
  180. and one way to learn is to first look
  181. at other peoples' work. I am going
  182. detail certain commands here so that
  183. you can do just that. The commands
  184. will be listed in UPPERCASE, but type
  185. them in as unshifted letters.
  186.  
  187. CAT
  188.  
  189. This command will show you what is on
  190. the disk drive. The disk drive sends
  191. the disk DIRECTORY (that's what it is
  192. called) to the computer, and COMAL
  193. prints it on the screen. The actual
  194. listing shows more than just program
  195. names. It shows how big they are,
  196. their names, and the file type. Each
  197. entry in the directory is called a
  198. file, and there are four types of
  199. files - PRG (program), SEQ
  200. (sequential - data files), REL
  201. (random - also data files), and USR
  202. (special files). Unlike the BASIC
  203. command:
  204.  
  205.   LOAD "$",8
  206.  
  207. COMAL will not erase the program in
  208. memory while showing a directory of a
  209. disk. You can slow the scrolling
  210. lines by holding down the CTRL key on
  211. the upper left hand side of the
  212. keyboard, or stop it by pressing the
  213. RUN/STOP key (right below the CTRL
  214. key). If you happen to have a dual
  215. drive (a two drive unit) you can add
  216. a '0' or a '1' after the command:
  217.  
  218.   cat 0    (This is for drive 0)
  219.   cat 1    (This is for drive 1)
  220.  
  221. LOAD
  222.  
  223. Once you know what is on the disk,
  224. you can load COMAL programs into
  225. memory with this command. It is
  226. similar to the BASIC LOAD command,
  227. except the default is now the disk
  228. drive, not the cassette. The
  229. following is an example of loading a
  230. program from the disk drive called
  231. filename:
  232.  
  233.   load "filename"
  234.  
  235. Only PRG type files can be loaded. Be
  236. careful, because other languages,
  237. like BASIC, also store their programs
  238. as PRG files and COMAL 0.14 will
  239. attempt to load any PRG type file. If
  240. you are not sure whether or not a
  241. program was written in COMAL 0.14,
  242. load the program and LIST it. Only
  243. COMAL 0.14 programs can be listed,
  244. any other type of program (BASIC,
  245. COMAL 2.0, etc) will not list. DO NOT
  246. RUN PROGRAMS WHICH DO NOT LIST. If
  247. you do, COMAL will become confused
  248. and stop functioning. The only thing
  249. to do after this has happened is to
  250. turn the computer off and reload
  251. COMAL.
  252.  
  253. LIST
  254.  
  255. Once a COMAL program is in memory,
  256. you will want to be able to see it.
  257. The command LIST will do just that,
  258. it will list the program to the
  259. screen. The first thing you will
  260. notice is you will want to slow or
  261. stop the listing (so you can study
  262. it). Just like a catalog command, you
  263. can use the CTRL key to slow, the
  264. RUN/STOP key to stop, and, just for
  265. LISTing a program, the space bar to
  266. pause the listing.
  267.  
  268. You will notice that each line has a
  269. number in front of it. These are
  270. called "line numbers" and COMAL uses
  271. them to keep track of the order of
  272. the program lines. The order goes
  273. from low (1) to high (9999), and you
  274. can use any line number between them.
  275.  
  276. The LIST command can also be used to
  277. show just part of a program. The
  278. following are some Examples to do
  279. just that:
  280.  
  281.   list          (all lines)
  282.   list 100-500
  283.   list 100-
  284.   list -500     (beginning to 500)
  285.  
  286. RUN
  287.  
  288. When the program you want has been
  289. loaded into memory, you start the
  290. program with the command RUN. The
  291. computer does a quick scan of the
  292. program to make sure it seems
  293. correct, and starts executing with
  294. the first line of the program. If an
  295. error occurs while the program is
  296. running, the program will stop
  297. executing, and COMAL will print the
  298. line number it is having the trouble
  299. with, and what the problem is.
  300.  
  301. MAKING ERRORS
  302.  
  303. There is a very good chance that you
  304. will make typing errors while trying
  305. these commands. COMAL checks each
  306. line you type for errors, and if it
  307. cannot understand what you typed, it
  308. will stop and give you an error
  309. message. It might go out to the disk
  310. drive and get the error message, or
  311. it might just print the message
  312. itself (that depends on whether you
  313. have error messages in memory or
  314. not). If you get an error, COMAL will
  315. put the cursor on the part of the
  316. line it is having trouble with so
  317. DON'T PANIC. Just make the correction
  318. and press the RETURN key again.
  319.  
  320. If the little red light on the disk
  321. drive starts blinking on and off
  322. while COMAL just sits there waiting
  323. for you to type something, try typing
  324. in the following command:
  325.  
  326. STATUS
  327.  
  328. This will print the error the disk
  329. drive had to the screen. Check your
  330. disk drive manual to find out what
  331. the problem is.
  332.